from DR_project.API import interface as TangwangAPI
import tqdm
import os
@profile
def img_Tangwang(img_path, dst_path) -> object:
    tangwang_list, tangwang_num, _ = TangwangAPI.interface2(img_path, dst_path)
    res = "糖网级别：" + str(tangwang_num) +"，概率：" +str(round(tangwang_list[tangwang_num],2))
    return tangwang_num,round(tangwang_list[tangwang_num],2)
BASE_PATH = os.path.dirname(os.path.abspath(__file__))
# 本工程路径
p_dic={}
for i in range(5):
    rrt='/Volumes/My Passport/0/'+str(i)+'/'
    p_dic[i]=['/Volumes/My Passport/0/'+str(i)+'/'+x for x in os.listdir(rrt)]
for t in range(5):
    print(t)
    file = open('dr_txt/dr'+str(t)+'.txt', 'w')
    file.write('名称')
    file.write('\t')
    file.write('概率')
    file.write('\t')
    file.write('预测级别')
    file.write('\t')
    file.write('真实级别')
    file.write('\t')
    file.write('\n')
    count=0
    for i in tqdm.tqdm(p_dic[t]):
        num,prob=img_Tangwang(i,'')
        file.write(i)
        file.write('\t')
        file.write(str(prob))
        file.write('\t')
        file.write(str(num))
        file.write('\t')
        file.write(str(t))
        file.write('\t')
        file.write('\n')
        count+=1
        if count==50:
            break
    file.close()
